Adaptive thread ID cache mechanism for autonomic performance tuning

ABSTRACT

An apparatus and method for inhibiting data cache thrashing in a multi-threading execution mode through simulating a higher level of associativity in a data cache. The apparatus temporarily splits a data cache into multiple regions and each region is selected according to a thread ID indicator in an instruction register. The data cache is split when the apparatus is in the multi-threading execution mode indicated by an enable cache split bit.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention generally relates to computing devices, morespecifically, the present invention relates to a processor architecturehaving an improved caching system.

2. Description of the Related Art

Memory access is essential in any computer system and substantiallyaffects the performance of a computer system. Much advancement has beenmade to improve memory access and among them, use of cache memory tostore data that is most likely to be next accessed in fast-couplingmemory typically on the main processor.

Cache memory improves computer's performance when a desired data isfound in the cache memory, but the cache memory does not contain all thedata needed for a particular application. Where a cache miss occurs,i.e., a needed data is not found in the cache memory, the needed datamust be brought in from another slower memory and data from the cachememory must be removed to yield the space for this needed data.

Cache misses increase especially when a computer is executing in asimultaneous multi-threading mode. In a multi-threading mode, multipleapplications access the memory simultaneously and a cache miss by oneapplication may thrash the cache for a second application by removing adata needed by the second application and thus causing a cache miss forthe second application.

As the size of cache memory increases, each cache memory access yieldsmore than one set of data. For example, in a 32 KB cache memory, eachaccess retrieves two pieces of data. After the two pieces of data isretrieved from the cache memory, additional steps must be taken toselect one of them for the application's use, thus adding more delay tothe data access. This additional delay becomes especially aggravatedwhen the number of data simultaneously retrieved increases.

SUMMARY OF THE INVENTION

The invention introduces a way to inhibit data cache thrashing during amulti-threading execution mode through simulating a higher level ofassociativity in a data cache. An apparatus according to the inventionincludes at least one instruction register having a thread ID indicator,an address generator having a cache index indicator and a plurality ofcache index bits, a cache memory, and a selector for selecting betweenthe thread ID indicator and the cache index indicator. The selectoroutputs an upper index indicator. When the thread ID indicator isselected by the selector, the thread ID indicator is output to the upperindex indicator, and the upper index indicator is concatenated with theplurality of cache index bits to form an address for retrieving an entryfrom the cache memory.

In another aspect, the invention is a method for inhibiting data cachethrashing in a multi-threading execution mode through simulating ahigher level of associativity in a data cache. The method includes thesteps of loading at least one instruction register having a thread IDindicator, generating an effective address having a cache indexindicator and a plurality of cache index bits, selecting an upper indexindictor between the thread ID indicator and the cache index indicator,forming an address by concatenating the upper index indicator with theplurality of cache index bits, and retrieving an entry from the cachememory indicated by the address.

Other objects, advantages, and features of the present invention willbecome apparent after review of the hereinafter set forth in BriefDescription of the Drawings, Detailed Description of the Invention, andthe Claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIGS. 1A-B illustrate a prior art architecture for a cache access.

FIG. 2 illustrates architecture for a cache access according to theinvention.

FIG. 3 illustrates an alternative architecture for a cache access.

DETAILED DESCRIPTION OF THE INVENTION

In this description, like numerals refer to like elements throughout theseveral views. The invention temporarily divides a cache to inhibitthrashing and to simulate the performance of higher level associativity.The cache is divided using thread ID bits without requiring extra selecttime.

Generally, a one level (L1) cache is unable to implement a high setassociativity to support a simultaneous multi-threading execution modewithout significant costs in area, power, additional access latency, andsignificant redesign resource and schedule. FIG. 1A illustrates aproblem with a L1 cache. An address generator 105 generates an effectiveaddress 106 using information from two registers RA 102 and RB 104. Theeffective address 106 is fed to a cache memory 107 having two sets ofdata 108 and 110. The effective address is connected to two comparators114 and 116 for use in a 2-way late selecting unit 118, which willselect which data to output to a cache data bus.

The late selecting unit can become more complex if more data are neededfrom a single cache memory access. FIG. 1B illustrates an example, wheneight comparators will be needed if eight pieces of data 122 areretrieved from the cache memory, and a 8-way late selecting unit 120 isneeded.

FIG. 2 illustrates an architecture 200 according to the invention. Athread ID indicator 222 is added to an instruction register 220.Although only one instruction register 220 is shown, there can be morethan one instruction register when the system is in the multi-threadexecution mode. The thread ID indicator can one bit or more bitsdepending how a cache memory is used during a multi-thread executionmode. This thread ID indicator 222 and bit 0 of an effective addressfrom the address generator 205 are connected to a selector 224. Bit 0 ofthe effective address, shown as element 208, is also known as the cacheindex indicator. The rest of bits from the effective address are thecache index bits 210. The selector 224 is controlled by a bit (enablecache split indicator) 234 from a machine state register (MSR) 232 andthe selector 224 selectively allows either the thread ID indicator orcache index bit 0 be connected to its output. This output (upper indexindicator) is concatenated with the cache index bits 210 from theeffective address to form an index into the data cache 207.

If the system is in a multi-thread execution mode and the operatingsystem, or hardware, is aware of an application that may causethrashing, the enable cache split indicator 234 will be set, which inturn directs the selector 224 to connect the thread ID indicator 222 tothe selector's output. An application may cause thrashing if it involvestechnical streaming, i.e., loop operation that involves heavycomputation, and this may be indicated by a streaming bit being set bythe operating system. The thread ID indicator 222 divides the cache 207into two halves, upper half 228 and lower half 230. The index formed bythe thread ID indicator 222 and the rest of effective address 210retrieves a set of data from either upper half 228 or lower half 230.The 2-way late selecting unit 218 then selects either a data from cacheset 0 or cache set 1 to be output onto the cache data bus.

The enable cache split bit 234 is set by the operating system when thecache 207 is divided to support the multi-thread execution mode. Bysetting the enable cache split bit 214 and using the thread ID indicator222, the 2-way late selecting unit 218 can be kept simple and haveminimal delay.

The embodiment shown in FIG. 2 minimizes cache thrashing when a cachemiss from a first application causes a data needed by a secondapplication to be discarded. By setting the enable cache split bit,dividing the cache into different regions, and associating these regionswith different applications, the thrashing is minimized withoutincurring additional delays with the late selecting unit.

FIG. 3 illustrates an alternative embodiment 300 for dynamicallysplitting the cache. A system may be in a cache thrashing situation ifthere is a substantial number of cache misses. For a system with twoapplications running, two cache miss counters 318 and 320 can be set up,one for each application. If application 1 has a cache miss, thencounter 320 is incremented. If application 0 has a cache miss, thencounter 318 is incremented. The cache miss counters are compared with areference counter 322. Each cache miss counter 318, 320 is reset when anew application start is started.

Instructions for each application is loaded in one instruction register,and for a system that supports two simultaneous applications twoinstruction registers 302, 304 are used. The two instruction registers302, 304 are identical. The instruction register 304 has a stream IDindicator 308 to indicate the application is in stream mode, i.e., in acomputational loop. The stream ID indicator 308 is set by hardware orthe operating system. The instruction register 304 also has a valid bit308 that is normally set to indicate that instruction in the instructionbuffer is valid. The valid bit 308 is unset by hardware if there is abranch condition or a cache miss.

If either instruction register has the stream ID indicator 308 set andthe valid bit 310 unset and either cache miss counter exceeds thereference counter 322 and the enable cache split bit 342 also set, thenthe 2-way late selecting unit 336 will select the thread ID indicator334. The thread ID indicator 334 is from an instruction registercurrently accessing the cache memory.

Although the invention is described in scenarios supporting one or twothreads, the invention can be easily implemented to support more threadswithout departing from the spirit of the invention.

In the context of the invention, the method may be implemented, forexample, by operating portion(s) of a computing device to execute asequence of machine-readable instructions. The instructions can residein various types of signal-bearing or data storage media. The media maycomprise, for example, RAM registers, or other memory components of theprocessor.

While the invention has been particularly shown and described withreference to a preferred embodiment thereof, it will be understood bythose skilled in the art that various changes in form and detail maybemade without departing from the spirit and scope of the presentinvention as set for the in the following claims. Furthermore, althoughelements of the invention may be described or claimed in the singular,the plural is contemplated unless limitation to the singular isexplicitly stated.

1. An apparatus for inhibiting data cache thrashing in a multi-threadingexecution mode through simulating a higher level of associativity in adata cache, comprising: at least one instruction register, the at leastone instruction register having a thread ID indicator; an addressgenerator having a cache index indicator and a plurality of cache indexbits; a cache memory; and a selector for selecting between the thread IDindicator and the cache index indicator, the selector outputting anupper index indicator, wherein when the thread ID indicator is selectedby the selector, the thread ID indicator is output to the upper indexindicator, and the upper index indicator is concatenated with theplurality of cache index bits to form an address for retrieving an entryfrom the cache memory.
 2. The apparatus of claim 1, further comprising amachine state register, the machine state register having an enablecache split indicator that, at least, controls the selector.
 3. Theapparatus of claim 1, further comprising at least one cache misscounter, the at least one cache miss counter counting cache misses,wherein the at least one cache miss counter controls the selector. 4.The apparatus of claim 1, wherein each thread ID indicator furthercomprises a plurality of bits.
 5. The apparatus of claim 1, wherein eachthread ID indicator further comprises a single bit.
 6. A method forinhibiting data cache thrashing in a multi-threading execution modethrough simulating a higher level of associativity in a data cache,comprising the steps of: loading at least one instruction register, theat least one instruction register having a thread ID indicator;generating an effective address having a cache index indicator and aplurality of cache index bits; selecting an upper index indictor betweenthe thread ID indicator and the cache index indicator; forming anaddress by concatenating the upper index indicator with the plurality ofcache index bits; and retrieving an entry from the cache memoryindicated by the address.
 7. The method of claim 6, wherein the step ofselecting an upper index indicator further comprises the steps of:checking an enable cache indicator in a machine state register; if theenable cache indicator is set, selecting the thread ID bit; and if theenable cache indicator is not set, selecting the cache index indicator.8. The method of claim 6, wherein the step of selecting an upper indexindicator further comprises the steps of: counting cache misses; if thenumber of cache misses exceeds a predefined limit, selecting the threadID bit; and if the number of cache misses is less than the predefinedlimit, selecting the cache index indicator.
 9. The method of claim 6,wherein each instruction register further comprises a stream IDindicator, wherein the step of selecting an upper index indicatorfurther comprises the steps of: checking a valid indicator and thestream ID indicator of the at least one instruction register; and if atleast one instruction register having both the valid indicator and thestream ID indicator set, selecting the thread ID bit.
 10. An apparatusfor inhibiting data cache thrashing in a multi-threading execution modethrough simulating a higher level of associativity in a data cache,comprising: a first means for storing instruction having a thread IDindicator; a second means for generating addresses having a cache indexindicator and a plurality of cache index bits; a third means for storingdata; and a fourth means for selecting between the thread ID indicatorand the cache index indicator, the fourth means having an upper indexindicator, wherein when the thread ID indicator is set and selected bythe fourth means, the thread ID indicator is connected to the upperindex indicator, and the upper index indicator is concatenated with theplurality of cache index bits to form an address to retrieve an entryfrom the third means.